package com.example.opengl.avengine

import com.alibaba.android.arouter.facade.annotation.Route
import com.android.baselibrary.base.BaseActivity
import com.example.opengl.R
import com.example.opengl.databinding.ActivityEglCustomPlayBinding
import com.example.opengl.egl.CustomerGLRender
import com.example.opengl.main.OpenGLPath
import com.example.opengl.main.OpenGlMainActivity
import com.example.opengl.render.video.VideoDrawer

@Route(path = OpenGLPath.OPENGL_CUSTOM_EGL)
class CustomPlayerActivity:BaseActivity<ActivityEglCustomPlayBinding>() {
    override fun getLayoutId(): Int  = R.layout.activity_egl_custom_play
    val path = OpenGlMainActivity.VIDEO_PATH

    override fun initView() {
        val  videoDrawer = VideoDrawer()
        val render = CustomerGLRender(videoDrawer)
        val avEngine = AVEngine.getVideoEngine()
        avEngine.setRender(render)
        avEngine.configure(mBinding.surface)
        avEngine.create()
        val path2 = "/storage/emulated/0/85214.mp4"
        val audio =  AVAudio(-1,path)
        val video = AVVideo(true,-1,path)



       /* avEngine.addComponent(video){}
        avEngine.addComponent(audio){}*/

        val audio2 =  AVAudio(-1,path2)
        val video2 = AVVideo(true,-1,path2)

        avEngine.addComponent(video2){}
        avEngine.addComponent(audio2){}
        mBinding.button.setOnClickListener {
            avEngine.togglePlayPause()
        }
    }

    override fun initListener() {

    }
}